using System;
using System.Drawing;

using SdlDotNet.Graphics;

using Game.Utils;
using Game.Input;
using Game.Output;

namespace Game.World
{
	public class CTerrain
	{
		private Surface		m_surface;		
		private Point		m_position;
		private CCountry	m_country;

		public CTerrain(CCountry p_country)		
		{
			CConsole.ReportClassInit(System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name);
			CConsole.ReportParam("p_country.Name",  p_country.Name);
			
			m_country = p_country;
			
			Initialize();
		}
		
		private void Initialize()
		{
			m_position = new Point(0, 0);
			
			CSurfaceFactory.CreateSurface(out m_surface, m_country.Surface.Size);
		}
		
		public void Update()
		{
			Point tmp = new Point(0, 0);
			
			for (int y = 0; y < m_country.MapSize.Height; y++)
			{
				for (int x = 0; x < m_country.MapSize.Width; x++)
				{
					tmp.X = -32 + m_country.Origin.X + x * 32 - y * 32;
					tmp.Y =   0 + m_country.Origin.Y + x * 16 + y * 16;
					
//					m_surface.Blit(
//						CTilesets.tilesets[(int)CTilesets.ID.ONE],
//						tempPosition,
//						CTilesets.GetSpriteRect((int)CTilesets.ID.ONE, 38)
//					);
				}
			}	
		}
		
		public void Render(ref Surface p_surface)
		{
			p_surface.Blit(m_surface, m_position);
		}
		
		#region properties
		
		public Surface Surface
		{
			get {
				return m_surface;
			}
		}
		
		#endregion
		
	}
}
